#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
 int main()
{
	int l, m;
	cin >> l >> m;
	while (m--) {
		int a, b;
		cin >> a >> b;
		for (int i = a; i <= b; i++) {
			arr[i] = 1;
		}
	}
	int count = 0;
	for (int i = 0; i < l + 1; i++) {
		if (arr[i] == 0) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}